package io.github.biezhi.elves.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import io.github.biezhi.elves.qcc.model.CompBasic;
import io.github.biezhi.elves.qcc.model.CompQccCrawl;
import io.github.biezhi.elves.qcc.model.CompUniscid;

public interface QccUniscidMapper {

	/**
	 * 查询未爬取的工商企业，即IS_SPIDER=0
	 * @return
	 */
//	@Select("select customer as compName from t_gd_customer_list_sy where is_spider = 0 limit #{num}")
	@Select("select name as compName from cq_custmer_sydw where is_spider = 0 limit #{num}")
//	@Select("select customer as compName from t_gd_customer_list_sy_tmp_dis where is_spider = 0 limit #{num}")
	public List<CompBasic> queryCompBasic(Integer num);
	
	/**
	 * 根据compName更新爬取状态
	 * @param compName
	 */
	@Update("update cq_custmer_sydw set is_spider=1 where name=#{compName}")
//	@Update("update t_gd_customer_list_sy_tmp_dis set is_spider=1 where customer=#{compName}")
	void updateSpiderState(String compName);

	/**
	 * 将爬取出来的数据存放到数据库表中
	 */
	@Insert("INSERT INTO cq_custmer_sydw_res (comp_name, dom, opscope, industry) "
			+"VALUES (#{compName}, #{dom}, #{opscope}, #{industry})")
//	@Insert("INSERT INTO comp_list_res (comp_name, uniscid, dom, opscope, name, regcap, tel, compType, "
//			+ "status, regorg, estdate, industry) "
//			+"VALUES (#{compName}, #{uniscid}, #{dom}, #{opscope}, #{name}, #{regcap}, #{tel}, #{compType}, #{status}"
//			+ ", #{regorg}, #{estdate}, #{industry})")
//	@Insert("INSERT INTO t_gd_customer_list_sy_tmp_qcc (comp_name, uniscid, dom, opscope, name, regcap, tel) "
//			+"VALUES (#{compName}, #{uniscid}, #{dom}, #{opscope}, #{name}, #{regcap}, #{tel})")
	public void insertSpiderData(CompUniscid compUniscid);
	
}
